var timer : float = 0;
var change : boolean = false;
var framesLeft : Texture2D[];
var framesRight : Texture2D[];
var framesPerSeconds : float;

function Start () 
{

}

function Update () 
{
	timer += Time.deltaTime;
	
	if(timer > 5)
	{
		change =! change;
		timer = 0;
	}
	
	if(change)
	{
		transform.position.x += 1 * Time.deltaTime;
		ToLeft();
	}
	
	if(change == false)
	{
		transform.position.x -= 1 * Time.deltaTime;
		ToRight();
	}
}

function ToRight()
{
	var index : int = Time.time * framesPerSeconds;
	index = index % framesLeft.Length;
	renderer.material.mainTexture = framesLeft[index];
}

function ToLeft()
{
	var index : int = Time.time * framesPerSeconds;
	index = index % framesRight.Length;
	renderer.material.mainTexture = framesRight[index];
}